package com.sky.mapper;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AdminOrderMapper {

    List<OrderVO> getDetails(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select count(1) from orders")
    long getCount();
    @Select("select * from orders where id=#{id}")
    OrderVO getDetailsById(Long id);
    @Select("select count(1) from orders where status=3")
    Integer getCinfirmedCount();
    @Select("select count(1) from orders where status=4")
    Integer getDeliveryInProgressCount();
    @Select("select count(1) from orders where status=2")
    Integer getToBeConfirmedCount();

    @Update("update sky_take_out.orders set status=5 ,delivery_time=NOW() where id=#{id}")
    void completeById(Long id);
    @Update("update sky_take_out.orders set status=3 where id=#{id}")
    void confirmById(OrdersConfirmDTO ordersConfirmDTO);

    @Update("update sky_take_out.orders set rejection_reason =#{rejectionReason},status=6 where id=#{id}")
    void setRejectionReason(OrdersRejectionDTO ordersConfirmDTO);
    @Update("update sky_take_out.orders set status=4 where id=#{id}")
    void deliveryById(Long id);
    @Update("update sky_take_out.orders set cancel_reason=#{cancelReason}, status=6 where id=#{id}")
    void setCancelReason(OrdersCancelDTO ordersCancelDTO);
}
